//
//  SawScrollTiitModel.m
//  优学荟管理系统
//
//  Created by edz on 2018/3/1.
//  Copyright © 2018年 星道三好. All rights reserved.
//

#import "SawScrollTiitModel.h"

@implementation SawScrollTiitModel
-(void)dataWithOrder:(void(^)(NSDictionary *dataDic))dataBlock
{
    NSString *url = @"yxhUser.do?action=informationNews";
    
    [SVProgressHUD setDefaultStyle:(SVProgressHUDStyleCustom)];
    [SVProgressHUD  setBackgroundColor:ColorRGB(4, 4, 4)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
    [SVProgressHUD showWithStatus:LLLoading];
    
    NSLog(@"%@  %@",LLBaseURL(url),[AccountTool shareAccountTool].currentAccount.authCode);
    [NetManager Get:LLBaseURL(url) Auth:YES Params:nil Success:^(id Obj) {
        if ([[Obj valueForKey:@"code"] integerValue] == 1000) {
            
            if (dataBlock) {
                dataBlock(Obj[@"t"]);
            }
            [SVProgressHUD dismiss];
            
            
        }
        else
        {
           
            [SVProgressHUD showErrorWithStatus:Obj[@"msg"]];
        }
    } Fail:^(NSError *Error) {
       
        [SVProgressHUD showErrorWithStatus:Error.userInfo[@"NSLocalizedDescriptionKey"]];
    }];
    
}
-(void)dataWithSheet:(void(^)(NSArray *dataArr))dataBlock
{
    NSString *url = @"yxhUser.do?action=informationCategoryList";
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        [SVProgressHUD setDefaultStyle:(SVProgressHUDStyleCustom)];
        [SVProgressHUD  setBackgroundColor:ColorRGB(4, 4, 4)];
        [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
        [SVProgressHUD showWithStatus:LLLoading];
        
    });
    
    NSLog(@"%@  %@",LLBaseURL(url),[AccountTool shareAccountTool].currentAccount.authCode);
    [NetManager Get:LLBaseURL(url) Auth:YES Params:nil Success:^(id Obj) {
        if ([[Obj valueForKey:@"code"] integerValue] == 1000) {
            
            if (dataBlock) {
                dataBlock(Obj[@"t"]);
            }
            
           
                [SVProgressHUD dismiss];
         
        }
        else
        {
            
            [SVProgressHUD showErrorWithStatus:Obj[@"msg"]];
        }
    } Fail:^(NSError *Error) {
        
        [SVProgressHUD showErrorWithStatus:Error.userInfo[@"NSLocalizedDescriptionKey"]];
    }];
    
}
-(void)cellWithSheet:(NSInteger)ID WithDataArr:(void(^)(NSArray *dataArr))dataBlock
{
    NSString *url = [NSString stringWithFormat:@"yxhUser.do?action=getInformationByCategoryId&categoryId=%ld&startTime=2018-01-01&endTime=2018-12-12",ID];
    dispatch_async(dispatch_get_main_queue(), ^{
        
            [SVProgressHUD setDefaultStyle:(SVProgressHUDStyleCustom)];
            [SVProgressHUD  setBackgroundColor:ColorRGB(4, 4, 4)];
            [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
            [SVProgressHUD showWithStatus:LLLoading];
        
    });

    
    NSLog(@"%@  %@",LLBaseURL(url),[AccountTool shareAccountTool].currentAccount.authCode);
    [NetManager Get:LLBaseURL(url) Auth:YES Params:nil Success:^(id Obj) {
        if ([[Obj valueForKey:@"code"] integerValue] == 1000) {
            
            if (dataBlock) {
                dataBlock(Obj[@"t"][@"dataList"]);
            }
            [SVProgressHUD dismiss];
            
            
        }
        else
        {
            
            [SVProgressHUD showErrorWithStatus:Obj[@"msg"]];
        }
    } Fail:^(NSError *Error) {
        
        [SVProgressHUD showErrorWithStatus:Error.userInfo[@"NSLocalizedDescriptionKey"]];
    }];
    
}
@end
